package com.slicktechnologies.shared.common.productlayer;
import com.google.gwt.core.shared.GwtIncompatible;
import com.google.gwt.editor.client.Editor.Ignore;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Embed;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.EntitySubclass;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.OnLoad;
import com.googlecode.objectify.annotation.OnSave;
import com.simplesoftwares.client.library.helperconstants.FormTypes;
import com.simplesoftwares.rebind.annatonations.TableAnnotation;
import com.slicktechnologies.client.config.configurations.ConfigTypes;
import com.slicktechnologies.shared.MyUtility;


/**
 * Represents product only for sell or purchase.
 */
@EntitySubclass (index=true)
@Embed
public class ItemProduct extends SuperProduct 
{	
	/***********************************************Entity Attributes****************************************************/
	/**  If true product is for sell. */
	@Index 
	protected boolean isSellProduct;
	
	/** if true product is for purchase. */
	protected boolean isPurchaseProduct;

	/** The vat tax entity. */
	protected Tax vatTax;
	
	/** it represents the remainder about when to purchase product in the inventory */
	protected int reOrderQuantity;
	
	/**  The barcode for this product. */
	@Index
	protected String barcode;

	/**  The brand of this product. */
	@Ignore
	protected String brandName;
	
	protected String model;
	protected String serialNumber;
	
	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 7252002290923932933L;

	/***********************************************Relational Attributes****************************************************/
	protected Key<Brand> brandKey;
	
	/***********************************************Default Ctor****************************************************/
	/** Instantiates a new item product */
	public ItemProduct()
	{
		super();
		vatTax=new Tax();
		barcode="";
		brandName="";
		vatTax=new Tax();
		brandKey=null;
		brandName="";
		
	}
	
	/***********************************************Getter/Setter****************************************************/
	/**
	 * Checks if is sell product.
	 *
	 * @return true, if is sell product
	 */
	@TableAnnotation(ColType = FormTypes.TEXTCOLUM, colNo = 7, isFieldUpdater = false, isSortable = true, title = "Sell Product")
	public boolean isSellProduct() {
		return isSellProduct;
	}
	
	/**
	 * Sets the sell product.
	 *
	 * @param isSellProduct the new sell product
	 */
	public void setSellProduct(boolean isSellProduct) {
		this.isSellProduct = isSellProduct;
	}
	
	/**
	 * Checks if is purchase product.
	 *
	 * @return true, if is purchase product
	 */
	public boolean isPurchaseProduct() {
		return isPurchaseProduct;
	}
	
	/**
	 * Sets the purchase product.
	 *
	 * @param isPurchaseProduct the new purchase product
	 */
	public void setPurchaseProduct(boolean isPurchaseProduct) {
		this.isPurchaseProduct = isPurchaseProduct;
	}
	
	/**
	 * Gets the vat tax entity.
	 *
	 * @return the vat tax entity
	 */
	@TableAnnotation(ColType = FormTypes.TEXTCOLUM, colNo = 6, isFieldUpdater = false, isSortable = false, title = "Vat")
	public Tax getVatTax() {
		return vatTax;
	}
	
	/**
	 * Sets the vat tax entity.
	 *
	 * @param vatTaxEntity the new vat tax entity
	 */
	public void setVatTax(Tax vatTaxEntity) {
		this.vatTax = vatTaxEntity;
	}
	
	/**
	 * Gets the barcode.
	 *
	 * @return the barcode
	 */
	public String getBarcode() {
		return barcode;
	}
	
	/**
	 * Sets the barcode.
	 *
	 * @param barcode the new barcode
	 */
	public void setBarcode(String barcode)
	{
		if(barcode!=null)
			this.barcode = barcode.trim();
	}
	
	/**
	 * Gets the category.
	 *
	 * @return the category
	 */
	
	
	/**************************************************Relation Managment Part**********************************************/
	@OnSave
	@GwtIncompatible
	public void OnSave()
	{
		super.onSave();
		
	}
	
	public String getBrandName() {
		return brandName;
	}

	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getSerialNumber() {
		return serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	@OnLoad
	@GwtIncompatible
	public void OnLoad()
	{
		super.onLoad();
	}
	/***********************************************************************************************************************/
}


